<?php
/**
 * Created by PhpStorm
 * User: 龍zero
 * Date: 2022-04-10
 * Time: 16:28
 */
declare(strict_types=1);

namespace App\Request\Users;

use Hyperf\Validation\Request\FormRequest;

class UpdateUserRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'username' => 'between:2,10',
            'email' => 'email',
            'nickname' => 'between:2,10',
            'avatar' => 'max:500'
        ];
    }
    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        return [
            'username.between' => '用户名必须在2-10个字符之间',
            'email.email'  => '邮箱格式不正确',
            'nickname.between'  => '用昵称必须在2-10个字符之间',
            'avatar.max' => '用户头像路径不得超过500个字符',
        ];
    }
}
